package com.xinqi.modules.exam.student.service;

import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.Param;
import com.xinqi.modules.exam.paper.domain.CourseExamPaperEntity;
import com.xinqi.modules.exam.paper.enums.ExamStatusEnum;
import com.xinqi.modules.exam.student.domain.CourseExamPaperStudentEntity;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentBatchDelDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentCreateDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentDeleteDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentManualDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentMarkDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentQueryDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentRejectDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentStartDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentSubmitDTO;
import com.xinqi.modules.exam.student.dto.req.CourseExamPaperStudentUpdateDTO;
import com.xinqi.modules.exam.student.dto.rsp.CourseExamPaperExtractResultDTO;
import com.xinqi.modules.exam.student.dto.rsp.CourseExamPaperStudentDetailDTO;
import com.xinqi.modules.exam.student.dto.rsp.CourseExamPaperStudentListDTO;
import com.xinqi.modules.exam.student.dto.rsp.CourseExamPaperStudentResultDTO;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.Valid;
import java.util.List;

/**
 * 课程测评学生答题服务层
 *
 * @author: linkai
 * @date: 2023/07/02
 */
public interface CourseExamPaperStudentService {
    /**
     * 分页查询 课程测评学生答题数据
     */
    PageInfo<CourseExamPaperStudentResultDTO> page(Param pageable, CourseExamPaperStudentQueryDTO query);

    /**
     * 查询 课程测评学生答题数据
     */
    List<CourseExamPaperStudentResultDTO> find(CourseExamPaperStudentQueryDTO query);

    /**
     * 根据id查询 课程测评学生答题数据
     */
    CourseExamPaperStudentResultDTO findById(Long id);

    /**
     * 新增 课程测评学生答题数据
     */
    Long insert(@Valid CourseExamPaperStudentCreateDTO dto);

    /**
     * 根据id修改 课程测评学生答题数据
     */
    Boolean updateById(@Valid CourseExamPaperStudentUpdateDTO dto);

    /**
     * 根据id删除 课程测评学生答题数据
     */
    Boolean deleteById(Long id);

    /**
     * 根据id删除 课程测评学生答题数据
     */
    Boolean deleteById(CourseExamPaperStudentDeleteDTO dto);

    @Transactional(rollbackFor = Exception.class)
    void generateStudentPaper(Long examId);

    Boolean isCanPaper(Long examId);

    Boolean isCanPaper(ExamStatusEnum es);

    Boolean isCanSubmit(Long examId, CourseExamPaperStudentEntity entity);

    Boolean isCanSubmit(ExamStatusEnum examStatus, CourseExamPaperStudentEntity entity);

    CourseExamPaperStudentDetailDTO findPaperDetail(Long id, boolean isShowAnswer);

    CourseExamPaperStudentDetailDTO findPaperDetail(Long examId, Long studentId, boolean isShowAnswer);

    CourseExamPaperStudentDetailDTO findCurrentPaperDetail(Long examId, Long studentId);

    CourseExamPaperEntity getExamPaper(Long examId);

    CourseExamPaperStudentEntity getStudentPaper(Long examId, Long studentId);

    @Transactional(rollbackFor = Exception.class)
    CourseExamPaperStudentDetailDTO startPaper(@Valid CourseExamPaperStudentStartDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean submitPaper(@Valid CourseExamPaperStudentSubmitDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean markPaper(@Valid CourseExamPaperStudentMarkDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean rejectPaper(@Valid CourseExamPaperStudentRejectDTO dto);

    @Transactional(rollbackFor = Exception.class)
    void updateStatsData(Long examId);

    Boolean remindPaper(Long examId);

    @Transactional(rollbackFor = Exception.class)
    Boolean forcePaper(Long examId);

    List<CourseExamPaperStudentResultDTO> findList(CourseExamPaperStudentQueryDTO dto);

    List<CourseExamPaperStudentListDTO> findStudentList(CourseExamPaperStudentQueryDTO dto);

    PageInfo<CourseExamPaperStudentListDTO> pageStudentList(Param pageable, CourseExamPaperStudentQueryDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean screenSwitch(Long examId, Long studentId);

    @Transactional(rollbackFor = Exception.class)
    CourseExamPaperExtractResultDTO extractAnswer(Long examId, Long questionId);

    @Transactional(rollbackFor = Exception.class)
    void handlerEndExam(Long examId);

    @Transactional(rollbackFor = Exception.class)
    Boolean manualSupplement(@Valid CourseExamPaperStudentManualDTO dto);

    @Transactional(rollbackFor = Exception.class)
    Boolean batchDelUser(CourseExamPaperStudentBatchDelDTO dto);
}
